package cn.edu.lit.jsjxy.CourseExample.chapter8;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;

import cn.edu.lit.jsjxy.CourseExample.R;

public class MainActivity_chap8 extends AppCompatActivity implements View.OnClickListener
{
    Button btnSharedPrefs, btnFileOP, btnDatabase, btnDatabaseOP ;

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main_chap8);

        btnSharedPrefs = findViewById(R.id.btnSharedPrefs);
        btnFileOP = findViewById(R.id.btnFileOP);
        btnDatabase = findViewById(R.id.btnDatabase);
        btnDatabaseOP = findViewById(R.id.btnDatabaseOP);

        btnSharedPrefs.setOnClickListener(this);
        btnFileOP.setOnClickListener(this);
        btnDatabase.setOnClickListener(this);
        btnDatabaseOP.setOnClickListener(this);

        findViewById(R.id.btnDatabaseOP_ex8_2).setOnClickListener(this);
    }

    @Override
    public void onClick(View view)
    {
        Intent intent = new Intent();

        switch (view.getId())
        {
            case R.id.btnSharedPrefs:
                intent.setClass(this, SharedPrefsTestActivity.class);
                break;

            case R.id.btnFileOP:
                intent.setClass(this, FileOperationActivity.class);
                break;

            case R.id.btnDatabase:
                intent.setClass(this, DatabaseOperationActivity.class);
                break;

            case R.id.btnDatabaseOP:
                intent.setClass(this, DatabaseTestActivity.class);
                break;

            case R.id.btnDatabaseOP_ex8_2:
                intent.setClass(this, Activity_EX_8_2.class);
                break;
        }
        startActivity(intent);
    }
}
